/**
 * @file FOC.h
 * @author Aiano_czm
 * @brief
 */

#ifndef FOC_DRIVER_FOC_H
#define FOC_DRIVER_FOC_H
#define FOC_CONTROL_MODE_NUM 10
typedef enum{
    OPEN_LOOP_SPEED_CONTROL=0,
    OPEN_LOOP_POSITION_CONTROL,
    TORQUE_CONTROL,
    SPEED_CONTROL,
    POSITION_CONTROL,
    SPRING,
    SPRING_WITH_DAMP,
    DAMP,
    KNOB,
    ZERO_RESISTANCE
} FOC_CONTROL_MODE;

extern FOC_CONTROL_MODE mode;
extern float target_velocity;
extern float target_angle;

void FOC_init();
void BLDC_Ctrl(FOC_CONTROL_MODE mode);
float get_velocity(void);
void alignSensor(void);
float get_electrical_angle();
float get_mechanical_angle();
void encoderCalibration(void);
void velocityOpenLoop(float target_velocity);
void angelOpenLoop(float target_angle);
void velocityCloseLoop(float target_velocity);
void positionCloseLoop(float target_angle);
void setPhaseVoltage(float Uq, float Ud, float angle);
#endif //FOC_DRIVER_FOC_H
